package domain;

import utils.CommandAnalyzer;
import basic.Transaction;

//@author A0098891H
public class Expense extends Transaction {
	public static final int DEFAULT_CATEGORY = 0;
	public static final String DEFAULT_PAYMENTMETHOD = "CASH";
	
	//attributes
	private int _category;
	private PaymentMethod _paymentMethod;

	/**
	 * 
	 */
	public Expense() 
	{
		super();
		this._category = DEFAULT_CATEGORY;
		this._paymentMethod = new PaymentMethod(DEFAULT_PAYMENTMETHOD);;
	}
	
	/**
	 * @param xpn
	 */
	public Expense(Expense xpn)
	{
		this.set(xpn);
	}
	
	/**
	 * 
	 * @param xpn
	 * @Precondition 
	 * @Postcondition 
	 */
	public void set(Expense xpn)
	{
		super.set(xpn);
		this.set_category(xpn._category);
		this.set_paymentMethod(xpn._paymentMethod);
		this.set_frequency(xpn._frequency);
	}
	
	/**
	 *
	 * @see java.lang.Object#toString()
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public String toString()
	{
		return  _name + "," + _amount + "," + _id
				+ "," + CommandAnalyzer.PARAM_CATEGORY + _category
				+ "," + CommandAnalyzer.PARAM_PAYMENTMETHOD + _paymentMethod.toString() 
				+ "," + CommandAnalyzer.PARAM_PARTYINVOLVED + _partyInvolved
				+ "," + CommandAnalyzer.PARAM_MEMBER + _byMem 
				+ "," + CommandAnalyzer.PARAM_DATE + _date.toString() 
				+ "," + CommandAnalyzer.PARAM_FREQUENCY + _frequency
				+ "," + CommandAnalyzer.PARAM_COMMENTS + _comments
				+ "," + CommandAnalyzer.PARAM_TOTALAMOUNT + _totalAmount
				+ "," + CommandAnalyzer.PARAM_UPDATEDATE + _lastUpdateDate;
	}
	
	
	//getters and setters
	/**
	 * 
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public int get_category() {
		return _category;
	}
	/**
	 * 
	 * @param category
	 * @Precondition 
	 * @Postcondition 
	 */
	public void set_category(int category) {
		if(category!=CommandAnalyzer.NA_CATEGORY)
			this._category = category;
	}
	/**
	 * 
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public PaymentMethod get_paymentMethod() {
		return _paymentMethod;
	}
	/**
	 * 
	 * @param paymentMethod
	 * @Precondition 
	 * @Postcondition 
	 */
	public void set_paymentMethod(PaymentMethod paymentMethod) {
		if(paymentMethod.get_name()!=DEFAULT_PAYMENTMETHOD)
			this._paymentMethod = paymentMethod;
	}
	
}
